var md5 = require("md5.js");
var Global = require("../Global.js");

var mysign = {
	secret: Global.getAppSecret(),
	sort: function(b) {
		for (var a = Object.keys(b).sort(), c = {}, d = 0; d < a.length; d++) c[a[d]] = b[a[d]];
		return c
	},
	getSign: function(b) {
		b = mysign.sort(b);
		var a;
		a = mysign.secret;
		for (var c in b) a += c, a += b[c];
		a += mysign.secret;
		return md5.hex_md5(a)
	}
};

function getSign(param){
   return  mysign.getSign(param);
}

module.exports = {
  getSign: getSign
}